color21 2.2.0
Loading...
Searching...
No Matches
Color 21 Click Driver

API for configuring and manipulating Color 21 Click driver. More...

Topics

 Color 21 Registers List
 List of registers of Color 21 Click driver.
 Color 21 Registers Settings
 Settings for registers of Color 21 Click driver.
 Color 21 MikroBUS Map
 MikroBUS pin mapping of Color 21 Click driver.

Functions

void color21_cfg_setup (color21_cfg_t *cfg)
 Color 21 configuration object setup function.
err_t color21_init (color21_t *ctx, color21_cfg_t *cfg)
 Color 21 initialization function.
err_t color21_default_cfg (color21_t *ctx)
 Color 21 default configuration function.
err_t color21_generic_write (color21_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
 Color 21 I2C writing function.
err_t color21_generic_read (color21_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
 Color 21 I2C reading function.
err_t color21_write_reg (color21_t *ctx, uint8_t reg, uint8_t data_in)
 Color 21 write register function.
err_t color21_read_reg (color21_t *ctx, uint8_t reg, uint8_t *data_out)
 Color 21 read register function.
err_t color21_write_reg_word (color21_t *ctx, uint8_t reg, uint16_t data_in)
 Color 21 write register word function.
err_t color21_read_reg_word (color21_t *ctx, uint8_t reg, uint16_t *data_out)
 Color 21 read register word function.
err_t color21_check_communication (color21_t *ctx)
 Color 21 check communication function.
void color21_set_ldr_pin (color21_t *ctx, uint8_t state)
 Color 21 set ldr pin function.
uint8_t color21_get_int_pin (color21_t *ctx)
 Color 21 get int pin function.
uint8_t color21_get_io_pin (color21_t *ctx)
 Color 21 get io pin function.
err_t color21_set_reg_bank_access (color21_t *ctx, uint8_t reg_bank)
 Color 21 set reg bank access function.
err_t color21_disable_ext_led (color21_t *ctx)
 Color 21 disable ext led function.
err_t color21_enable_ext_led (color21_t *ctx, uint16_t led_curr)
 Color 21 enable ext led function.
err_t color21_set_integration_time_ms (color21_t *ctx, float int_time_ms)
 Color 21 set integration time ms function.
err_t color21_set_wait_time_ms (color21_t *ctx, float wait_time_ms)
 Color 21 set wait time ms function.
err_t color21_read_data (color21_t *ctx, color21_data_t *data_out)
 Color 21 read data function.

Detailed Description

API for configuring and manipulating Color 21 Click driver.

Any initialization code needed for MCU to function properly. Do not remove this line or clock might not be set correctly.

Function Documentation

◆ color21_cfg_setup()

void color21_cfg_setup ( color21_cfg_t * cfg)

Color 21 configuration object setup function.

This function initializes Click configuration structure to initial values.

Parameters
[out]cfg: Click configuration structure. See color21_cfg_t object definition for detailed explanation.
Returns
Nothing.
Note
The all used pins will be set to unconnected state.

◆ color21_check_communication()

err_t color21_check_communication ( color21_t * ctx)

Color 21 check communication function.

This function checks the communication by reading and verifying the device ID.

Parameters
[in]ctx: Click context object. See color21_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ color21_default_cfg()

err_t color21_default_cfg ( color21_t * ctx)

Color 21 default configuration function.

This function executes a default configuration of Color 21 Click board.

Parameters
[in]ctx: Click context object. See color21_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
This function can consist any necessary configuration or setting to put device into operating mode.

◆ color21_disable_ext_led()

err_t color21_disable_ext_led ( color21_t * ctx)

Color 21 disable ext led function.

This function disables the onboard LED.

Parameters
[in]ctx: Click context object. See color21_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ color21_enable_ext_led()

err_t color21_enable_ext_led ( color21_t * ctx,
uint16_t led_curr )

Color 21 enable ext led function.

This function enables the onboard LED with the selected led driver current.

Parameters
[in]ctx: Click context object. See color21_t object definition for detailed explanation.
[in]led_curr: LED Driver current in mA [4-258].
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ color21_generic_read()

err_t color21_generic_read ( color21_t * ctx,
uint8_t reg,
uint8_t * data_out,
uint8_t len )

Color 21 I2C reading function.

This function reads a desired number of data bytes starting from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See color21_t object definition for detailed explanation.
[in]reg: Start register address.
[out]data_out: Output read data.
[in]len: Number of bytes to be read.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ color21_generic_write()

err_t color21_generic_write ( color21_t * ctx,
uint8_t reg,
uint8_t * data_in,
uint8_t len )

Color 21 I2C writing function.

This function writes a desired number of data bytes starting from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See color21_t object definition for detailed explanation.
[in]reg: Start register address.
[in]data_in: Data to be written.
[in]len: Number of bytes to be written.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ color21_get_int_pin()

uint8_t color21_get_int_pin ( color21_t * ctx)

Color 21 get int pin function.

This function returns the INT pin logic state.

Parameters
[in]ctx: Click context object. See color21_t object definition for detailed explanation.
Returns
Pin logic state.
Note
None.

◆ color21_get_io_pin()

uint8_t color21_get_io_pin ( color21_t * ctx)

Color 21 get io pin function.

This function returns the IO pin logic state.

Parameters
[in]ctx: Click context object. See color21_t object definition for detailed explanation.
Returns
Pin logic state.
Note
None.

◆ color21_init()

err_t color21_init ( color21_t * ctx,
color21_cfg_t * cfg )

Color 21 initialization function.

This function initializes all necessary pins and peripherals used for this Click board.

Parameters
[out]ctx: Click context object. See color21_t object definition for detailed explanation.
[in]cfg: Click configuration structure. See color21_cfg_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ color21_read_data()

err_t color21_read_data ( color21_t * ctx,
color21_data_t * data_out )

Color 21 read data function.

This function checks if the spectral measurement data is ready and then reads data from all channels along with the STATUS and ASTATUS bytes.

Parameters
[in]ctx: Click context object. See color21_t object definition for detailed explanation.
[out]data_out: Spectral measurements data object. See color21_data_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ color21_read_reg()

err_t color21_read_reg ( color21_t * ctx,
uint8_t reg,
uint8_t * data_out )

Color 21 read register function.

This function reads data from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See color21_t object definition for detailed explanation.
[in]reg: Register address.
[out]data_out: Output read data.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ color21_read_reg_word()

err_t color21_read_reg_word ( color21_t * ctx,
uint8_t reg,
uint16_t * data_out )

Color 21 read register word function.

This function reads a data word starting from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See color21_t object definition for detailed explanation.
[in]reg: Start register address.
[out]data_out: Output read data word.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ color21_set_integration_time_ms()

err_t color21_set_integration_time_ms ( color21_t * ctx,
float int_time_ms )

Color 21 set integration time ms function.

This function sets the integration time in milliseconds by setting the ATIME and ASTEP registers.

Parameters
[in]ctx: Click context object. See color21_t object definition for detailed explanation.
[in]int_time_ms: Integration time in milliseconds [from COLOR21_INTEGRATION_TIME_MIN to COLOR21_INTEGRATION_TIME_MAX].
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ color21_set_ldr_pin()

void color21_set_ldr_pin ( color21_t * ctx,
uint8_t state )

Color 21 set ldr pin function.

This function sets the LDR pin logic state.

Parameters
[in]ctx: Click context object. See color21_t object definition for detailed explanation.
[in]state: Pin logic state.
Returns
None.
Note
None.

◆ color21_set_reg_bank_access()

err_t color21_set_reg_bank_access ( color21_t * ctx,
uint8_t reg_bank )

Color 21 set reg bank access function.

This function sets the register bank access.

Parameters
[in]ctx: Click context object. See color21_t object definition for detailed explanation.
[in]reg_bank:
  • 0 - Access to registers above 80h,
  • 1 - Access to registers from 20h to 7Fh.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ color21_set_wait_time_ms()

err_t color21_set_wait_time_ms ( color21_t * ctx,
float wait_time_ms )

Color 21 set wait time ms function.

This function sets the wait time in milliseconds by setting the WTIME register.

Parameters
[in]ctx: Click context object. See color21_t object definition for detailed explanation.
[in]wait_time_ms: Wait time in milliseconds [from COLOR21_WAIT_TIME_MIN to COLOR21_WAIT_TIME_MAX].
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ color21_write_reg()

err_t color21_write_reg ( color21_t * ctx,
uint8_t reg,
uint8_t data_in )

Color 21 write register function.

This function writes a desired data to the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See color21_t object definition for detailed explanation.
[in]reg: Register address.
[in]data_in: Data to be written.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ color21_write_reg_word()

err_t color21_write_reg_word ( color21_t * ctx,
uint8_t reg,
uint16_t data_in )

Color 21 write register word function.

This function writes a data word starting from the selected register by using I2C serial interface.

Parameters
[in]ctx: Click context object. See color21_t object definition for detailed explanation.
[in]reg: Start register address.
[in]data_in: Data word to be written.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.